<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="com.is.model.Student" %>
<%@page import="com.is.model.User" %>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.control.ParamClassControl"%>
<%@page import="com.is.util.DesData"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/InterStu/resources/image/favicon.ico" />
<link rel="stylesheet" type="text/css" href="../../resources/css/all.css" />
<script type="text/javascript" src="../../resources/js/jquery-1.8.1.js"></script>
<link href="../../resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resources/js/jquery.artDialog.js"></script>
<script type="text/javascript" src="../../resources/js/iframeTools.js"></script>
<script type="text/javascript">
	$(function(){
		var block = $("#magic_block");
		if($(".active a").position()){
			block.css("top",$(".active a").position().top+10)
			.data("oriTop",$(".active a").position().top)
		}
		/**/
		$(".deleteStu").click(function(){
			artDialog.fn.shake = function (){
			    var style = this.DOM.wrap[0].style,
			        p = [4, 8, 4, 0, -4, -8, -4, 0],
			        fx = function () {
			            style.marginLeft = p.shift() + 'px';
			            if (p.length <= 0) {
			                style.marginLeft = 0;
			                clearInterval(timerId);
			            };
			        };
			    p = p.concat(p.concat(p));
			    timerId = setInterval(fx, 13);
			    return this;
			};
			var temUrl = $(this).attr("rel");
			var dialog = $.dialog({
		    content: '<p>本次操作权限为高级管理员。<br/>请输入口令，以进行操作！</p>'
		    	+ '<input id="demo-labs-input" style="width:15em; padding:4px" />',
		    fixed: true,
		    id: 'Fm7',
		    icon: 'question',
		    okVal: '回答',
		    ok: function () {
		    	var input = document.getElementById('demo-labs-input');
		        
		    	if (input.value !== '\u614e\u91cd\u5220\u9664') {
		            this.shake && this.shake();// 调用抖动接口
		            input.select();
		            input.focus();
		            return false;
		        } else {
		            window.location = temUrl;
		        };
		    },
		    cancel: true
		});
		
		dialog.shake && dialog.shake();
		
		})
		/*exportData*/
		$("#export_data").click(function(){
			$.dialog.open('exportOptions.jsp',{width:460,height:400,title:"选择您要导出的列"});
		})
		$(".nav ul li").find("a").hover(
			function(){
				var $this = $(this);
				var newTop = $this.position().top;
				block.stop().animate({
					top:newTop+10
				})
			},
			function(){
				block.stop().animate({
					top:block.data("oriTop")+10
				})
			}
		)
		/*二级联动菜单*/
		$("[name='gradeYear']").change(function(){
			var temVal = $(this).val();
			if(temVal!= "%%"){
				$.ajax({
					type:"post",
					cache:false,
					url:"printClass.jsp",
					dataType:"html",
					data:{
						gradeYear: temVal
					},
					success:function(data){
						//alert(data);
						$("[name='ClassId']")[0].options.length=1;
						$("[name='ClassId']").append(data);
					}
				})
			} else{
				$("[name='ClassId']")[0].options.length=1;
			}
		})
		var h = $(".right").height();
		$(".left").height(h);
		$(".update").click(function(){
			$.dialog.open("/InterStu/update_info.jsp",{width:460,height:400,title:"个人信息"});
		})
		$('img').error(function(){
			this.src = "/InterStu/resources/image/man.GIF";
		})
	})

</script>
<title>留学生预科班</title>
</head>
<% 
    DesData des = new DesData();
	User cu =(User)session.getAttribute("user"); 
	response.setCharacterEncoding("utf-8");
	String name = "";
	String nationality = "";
	String CSCNumber = "";
	String gradeYear = "";
	String ClassId = "";
	String type = ParamUtil.getString(request,"type","0");
	if(type.equals("1")){
		name = ParamUtil.getString(request,"name",null);
		nationality = ParamUtil.getString(request,"nationality",null);
		CSCNumber = ParamUtil.getString(request,"CSCNumber",null);
		ClassId = ParamUtil.getString(request,"ClassId",null);
		gradeYear = ParamUtil.getString(request,"gradeYear",null);
		session.setAttribute("name",name);
		session.setAttribute("nationality",nationality);
		session.setAttribute("CSCNumber",CSCNumber);
		session.setAttribute("gradeYear",gradeYear);
		session.setAttribute("ClassId",ClassId);
	} else{
		name = (String)session.getAttribute("name");
		nationality = (String)session.getAttribute("nationality");
		CSCNumber = (String)session.getAttribute("CSCNumber");
		ClassId = (String)session.getAttribute("ClassId");
		gradeYear = (String)session.getAttribute("gradeYear");
	}
%>
<body>
<div class="header">
	<div class="title pr">
    	<a href="javascript:void(0);"><span class="update pa">个人信息</span></a>
        <span class="logout pa"><a class="hide" href="/InterStu/login/logout.jsp">退出</a></span>
    </div>
</div>
<div class="main">
	<div class="left"> 
	   <div class="infomation">
			<div class="photo">
			<%
			String picUrl = cu.getPicUrl();
			%>
				<img width='60' height="60" src = "<%=picUrl %>"  />
			</div>
			<div class="welcome">
				<%=cu.getName() %>,<br/>
				欢迎您使用！
			</div>
		</div>  	   	  	
    	<div class="nav">
        	<ul>	
        		<li class="pa" id="magic_block"></li>
            	<%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/stuyear/stuyear_start.jsp">新学期设置</a></li>
                <li><a href="/InterStu/pages/users/user_all.jsp">用户管理</a></li>
                <%} %>
                <li class="active"><a href="/InterStu/pages/students/student_add.jsp">学生管理</a></li>
                <li ><a href="/InterStu/pages/dictation/dictation_add.jsp">学生考核</a></li>
                <%if(cu!=null&&cu.getRole().equals("1")){ %>
                <li><a href="/InterStu/pages/assess/teacher_assess.jsp">教职人员管理</a></li>
                <%} %>
            </ul>
        </div>
    </div>
    <div class="right">
    	<div class="r1">
    	<table class="student tab">
    <tr>
      <%if(cu!=null&&cu.getRole().equals("1")){ %>
    	<td>
    		<a href="/InterStu/pages/students/student_add.jsp">添加学生</a>
		</td>
		<%} %>
		<td>
			<a class='current' href="/InterStu/pages/students/student_admin.jsp?id=<%=cu.getId() %>">查看学生</a>
		</td>
		<td>
			<a href="/InterStu/pages/attendance/attendance_add.jsp">学生出勤</a>
		</td>
    </tr>
    </table>
    	<form action="student_admin.jsp?type=1" method="post"> 
    	<table  class='table'>
    		<caption>请选择</caption>
    		<tbody>
    			<tr>
    				<td>中文名</td>
    				<td><input type='text' style="width:120px;" name="name" value="<%out.print((session.getAttribute("name")!=null)?(session.getAttribute("name")):"");%>"/></td>
    				<td>国籍（中文）</td>
    				<td><input type="text" style="width:120px;" name="nationality" value="<%out.print((session.getAttribute("nationality")!=null)?(session.getAttribute("nationality")):""); %>"/></td>
    				<td>CSC号</td>
    				<td><input type="text" style="width:120px;" name="CSCNumber" value="<%out.print((session.getAttribute("CSCNumber")!=null)?(session.getAttribute("CSCNumber")):""); %>"/></td>
    				<td>年级</td>
    				<td>
    				<select style="width:80px;" name="gradeYear">
    					<option value="%%">全部</option>
    					<% 
    						HashMap map = StudentControl.getGradeYear();
    						Iterator it = map.entrySet().iterator();
    						while(it.hasNext()){
    							Map.Entry entry = (Map.Entry)it.next();
    					%>
    						<option value="<%=entry.getKey() %>" <%=(session.getAttribute("gradeYear") != null && session.getAttribute("gradeYear").toString().equals(entry.getKey().toString()))?"selected":"" %>>
    							<%=entry.getValue() %>
    						</option>
    					<%	
    						}
    					%>
    				</select>
    				</td>
    				<td>班级</td>
    				<td><select style="width:110px;" name="ClassId">
    					<option value="%%">全部</option>
    					<%
    						
    						String grade = (String)session.getAttribute("gradeYear");
    						HashMap map2 = StudentControl.getClassName(grade);
							Iterator it2 = map2.entrySet().iterator();
							while(it2.hasNext()){
							Map.Entry entry2 = (Map.Entry)it2.next();
						%>
						<option value="<%=entry2.getKey()%>" <%=(session.getAttribute("ClassId")!=null && session.getAttribute("ClassId").toString().equals(entry2.getKey().toString()))?"selected":"" %>><%=entry2.getValue() %></option>
						<%
						} 
						%>
						</select> 
					</td>
					<td><input type="submit" value="查找"/></td>
    			</tr>
    		</tbody>
    	</table>
		</form>
        </div>
        <div class="r2">
        <form action="student_admin.jsp" method="post">
        <table class='table'>
        	<caption>搜索结果&nbsp;&nbsp;&nbsp;&nbsp;[<a id="export_data" href="javascript:void(0);">导出</a>]</caption>
			<thead>
			<tr>
				<th>护照姓名</th>
				<th>中文名</th>
				<th>国籍</th>
				<th>护照编号</th>
				<th>CSC</th>
				<th>班级</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
			<% 	//String chineseName, String nationality, String sex,  String classId, String csc, String level,
				// String major, int page, int rowsPerPage
				int pages = ParamUtil.getInt(request,"pages",1);
				int rowsPerPage = ParamUtil.getInt(request, "pageSize", 10);
				Student s = new Student();
				List<Student> list = new ArrayList<Student>();
				list = (List)StudentControl.getStudentMulti(name,nationality,"",ClassId,CSCNumber,"","",gradeYear,pages,rowsPerPage);
				List<Student> exportList = new ArrayList<Student>();
				exportList = (List)StudentControl.getAllStudentMulti(name,nationality,"",ClassId,CSCNumber,"","",gradeYear);
				session.removeAttribute("exportList");
				session.setAttribute("exportList",exportList);
				for(int i=0;i<list.size();i++){
					s = list.get(i);
			%>
			<tr>
				
				<td><%=s.getPassportName() %></td>
				<td><a href='update_student.jsp?sid=<%=des.encrypt(String.valueOf(s.getId())) %>'><%=s.getChineseName() %></a> </td>
				<td><%=s.getNationality() %></td>
				<td><%=s.getPassportNumber() %></td>
				<td><%=s.getCscNumber() %></td>
				<td><%=ParamClassControl.getClassName((Integer.parseInt(s.getClassId()))) %></td>
				<td><a href="javascript:void(0);" rel='del_student.jsp?sid=<%=des.encrypt(String.valueOf(s.getId())) %>' class="deleteStu" >删除</a></td>
			</tr>
			<%
				}
			%>
			
			</tbody>
			</table>
			<p class='bar'>
		<%
			out.println(StudentControl.pageInstance.getToolsMenu(pages));
		%></p>
		</form>
        </div>
    </div>
</div>
<div class="footer">
	<p>版权所有：东北师范大学留学生预科部&nbsp;&nbsp;  蓝旭工作室开发</p>
</div>
</body>
</html>
